/*
 * DataSource.js
 * Example using a data source
 *  
 *  
*/

response.setContentType("text/html");


function toTable(resultSet) {
	var buffer = "<table border=1>";
	for (var i=0; i< resultSet.size(); i++) {
		buffer += "<tr>";
		var record = resultSet.get(i);
		var keys = record.keys.toArray();
		if (i==0) {
			for (j in keys) {
				buffer += "<th>" + keys[j] + "</th>";
			}
			buffer +="</tr><tr>";
		}
		for (j in keys) {
			buffer += "<td>" + record.get(keys[j]) + "</td>";
		}
		buffer += "</tr>";
	}
	buffer += "</table>";
	return buffer;
}


var ds = data.getDataSource("JDBCDataSource");
//ds.setParam("region", "Western Europe");

var result = ds.doQuery();
var output = toTable(result)


var ds2 = data.getDataSource("JDBCRegionDataSource");
var result2 = ds2.doQuery();
output = toTable(result2) + output


output

 